
package com.shop.cloud.mall.admin.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shop.cloud.common.core.constant.CommonConstants;
import com.shop.cloud.mall.admin.service.ShopInfoService;
import com.shop.cloud.mall.common.entity.ShopDepositConfig;
import com.shop.cloud.mall.admin.mapper.ShopDepositConfigMapper;
import com.shop.cloud.mall.admin.service.ShopDepositConfigService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 店铺保证金设置
 *
 * @author
 * @date 2023-11-28 11:15:11
 */
@Service
@AllArgsConstructor
public class ShopDepositConfigServiceImpl extends ServiceImpl<ShopDepositConfigMapper, ShopDepositConfig> implements ShopDepositConfigService {

    private final ShopInfoService shopInfoService;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdate(ShopDepositConfig entity) {
        if(CommonConstants.YES.equals(entity.getEnable())){
            //开启保证金功能，则关闭所有未缴纳保证金的店铺
            shopInfoService.updateByDeposit();
            shopInfoService.removeCache();
        }
        return super.saveOrUpdate(entity);
    }
}
